package com.neusoft.controller;

import com.neusoft.entity.CheckRequest;
import com.neusoft.service.CheckRequestService;
import com.neusoft.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author akemihomurasama
 */
@RestController
@RequestMapping("/checkRequest")
@CrossOrigin
public class CheckRequestController {
    @Autowired
    private CheckRequestService checkRequestService;

    /**
     * 医生添加检查申请
     *
     * @param checkRequest 申请信息
     * @return 申请结果
     */
    @RequestMapping("/addCheck")
    public Result addCheck(@RequestBody CheckRequest checkRequest) {
        return checkRequestService.addCheck(checkRequest);
    }

    /**
     * 根据检查申请的状态查询申请信息
     *
     * @param checkState 检查申请的状态
     * @return 申请列表
     */
    @RequestMapping("/queryReqByState/{checkState}")
    public Result queryReqByState(@PathVariable("checkState") String checkState) {
        return checkRequestService.queryReqByState(checkState);
    }

    /**
     * 查询患者已缴费的检查申请的医技项目，同时查询检查申请id
     *
     * @param registerId 患者id
     * @param checkState 检查申请状态
     * @return 医技项目列表，检查申请id
     */
    @RequestMapping("/queryCheckById/{registerId}/{checkState}")
    public Result queryCheckById(@PathVariable("registerId") int registerId, @PathVariable("checkState") String checkState) {
        return checkRequestService.queryTechByPatient(registerId, checkState);
    }

    /**
     * 患者开始检查业务
     *
     * @param checkRequestId 检查申请id
     * @param empId          医生id
     * @return 更新结果
     */
    @RequestMapping("/patientBeginCheck/{empId}/{checkRequestId}")
    public Result patientBeginCheck(@PathVariable("empId") int empId, @PathVariable("checkRequestId") int checkRequestId) {
        return checkRequestService.patientBeginCheck(checkRequestId, empId);
    }

    /**
     * 患者检查完成后更新患者检查申请的信息
     *
     * @param checkRequest 信息
     * @return 跟新结果
     */
    @RequestMapping("/patientUpdateCheckRes")
    public Result patientUpdateCheckRes(@RequestBody CheckRequest checkRequest) {
        return checkRequestService.patientUpdateCheckRes(checkRequest);
    }

    /**
     * 根据检查申请id查询检查申请
     *
     * @param checkReqId 检查申请id
     * @return 检查申请信息
     */
    @RequestMapping("/queryCheckReqById/{id}")
    public Result queryCheckReqById(@PathVariable("id") Integer checkReqId) {
        return checkRequestService.queryCheckReqById(checkReqId);
    }

    /**
     * 查询患者所有检查项目
     *
     * @param registerId 患者id
     * @return 查询结果
     */
    @RequestMapping("/queryCheckByRegisterId/{registerId}")
    public Result queryCheckByRegisterId(@PathVariable int registerId) {
        return checkRequestService.queryCheckByRegisterId(registerId);
    }
}
